package com.googlecode.mvcguice.util;

import static com.google.common.base.Preconditions.checkNotNull;

import java.lang.reflect.Modifier;

import com.google.common.primitives.Primitives;

public class Types {
	private Types() {
	}

	public static boolean isSimpleType(Class<?> type) {
		checkNotNull(type, "Parameter 'type' must be not null");

		if (type.isPrimitive()) {
			return true;
		}
		if (Primitives.isWrapperType(type)) {
			return true;
		}
		if (type == String.class) {
			return true;
		}

		return false;
	}

	public static boolean isInstantiateable(Class<?> type) {
		final int modifiers = checkNotNull(type, "Parameter 'type' must be not null").getModifiers();
		return !(Modifier.isInterface(modifiers) || Modifier.isAbstract(modifiers));
	}
}
